<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class MN_Controller extends CI_Controller {

    //Page info
    protected $data = Array();
    protected $pageName = FALSE;
    protected $template = "main";
    protected $hasNav = TRUE;
    //Page contents
    protected $javascript = array();
    protected $css = array();
    protected $fonts = array();
    //Page Meta
    protected $title = FALSE;
    protected $description = FALSE;
    protected $keywords = FALSE;
    protected $author = FALSE;

    function __construct() {

        parent::__construct();
        $this->data["uri_segment_1"] = $this->uri->segment(1);
        $this->data["uri_segment_2"] = $this->uri->segment(2);
        $this->title = $this->config->item('site_title');
        $this->description = $this->config->item('site_description');
        $this->keywords = $this->config->item('site_keywords');
        $this->author = $this->config->item('site_author');

        $this->pageName = strToLower(get_class($this));
    }

    protected function _render($view) {
        //static
        $toTpl["javascript"] = $this->javascript;
        $toTpl["css"] = $this->css;
        $toTpl["fonts"] = $this->fonts;

        //meta
        $toTpl["title"] = $this->title;
        $toTpl["description"] = $this->description;
        $toTpl["keywords"] = $this->keywords;
        $toTpl["author"] = $this->author;

        //data
        $toBody["content_body"] = $this->load->view($view, array_merge($this->data, $toTpl), true);

        $toHeader["basejs"] = $this->load->view("template/basejs", $this->data, true);

        $toBody["header"] = $this->load->view("template/header", $toHeader, true);
        $toBody["footer"] = $this->load->view("template/footer", '', true);


        $toTpl["body"] = $this->load->view("template/" . $this->template, $toBody, true);


        //render view
        $this->load->view("template/layout", $toTpl);
       
    }
    public function removeCache()
    {
        $this->output->set_header('Last-Modified:'.gmdate('D, d M Y H:i:s').'GMT');
        $this->output->set_header('Cache-Control: no-store, no-cache, must-revalidate');
        $this->output->set_header('Cache-Control: post-check=0, pre-check=0',false);
        $this->output->set_header('Pragma: no-cache');
        //echo "entro borrar cache";
    }


}
